# Maintainer: Ryuta Suzuki <oroppas@gmail.com>

_realname=cycler
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}" "${MINGW_PACKAGE_PREFIX}-python2-${_realname}")
pkgver=0.10.0
pkgrel=4
pkgdesc="Composable style cycles"
arch=('any')
license=('BSD')
url="https://github.com/matplotlib/cycler"
makedepends=("${MINGW_PACKAGE_PREFIX}-python3-setuptools"
             "${MINGW_PACKAGE_PREFIX}-python2-setuptools"
             "${MINGW_PACKAGE_PREFIX}-python3-six"
             "${MINGW_PACKAGE_PREFIX}-python2-six")
checkdepends=("${MINGW_PACKAGE_PREFIX}-python3-nose"
              "${MINGW_PACKAGE_PREFIX}-python2-nose"
              "${MINGW_PACKAGE_PREFIX}-python3-coverage"
              "${MINGW_PACKAGE_PREFIX}-python2-coverage")
source=(${_realname}-${pkgver}.tar.gz::"https://github.com/matplotlib/${_realname}/archive/v${pkgver}.tar.gz")
sha256sums=('b6d217635e03024196225367b1a438996dbbf0271bec488f00584f0e7dc15cfa')

prepare() {  
  cd "${srcdir}"
  for pver in {2,3}; do 
    rm -rf python${pver}-build-${CARCH} | true
    cp -r "${_realname}-${pkgver}" "python${pver}-build-${CARCH}"
  done
}

build() {  
  for pver in {2,3}; do  
    msg "Python ${pver} build for ${CARCH}"  
    cd "${srcdir}/python${pver}-build-${CARCH}"
    ${MINGW_PREFIX}/bin/python${pver} setup.py build
  done
}

check() {  
  for pver in {2,3}; do  
    msg "Python ${pver} test for ${CARCH}"  
    cd "${srcdir}/python${pver}-build-${CARCH}"
    ${MINGW_PREFIX}/bin/python${pver} run_tests.py
  done
}

package_python3-cycler() {
  depends=(
    "${MINGW_PACKAGE_PREFIX}-python3"
    "${MINGW_PACKAGE_PREFIX}-python3-six"
  )
  cd "${srcdir}/python3-build-${CARCH}"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python3 setup.py install --root="${pkgdir}" --prefix=$MINGW_PREFIX --optimize=1
  install -D -m644 LICENSE "${pkgdir}/$MINGW_PREFIX/share/licenses/python3-cycler/LICENSE"
}

package_python2-cycler() {
  depends=(
    "${MINGW_PACKAGE_PREFIX}-python2"
    "${MINGW_PACKAGE_PREFIX}-python2-six"
  )
  cd "${srcdir}/python2-build-${CARCH}"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python2 setup.py install --root="${pkgdir}" --prefix=$MINGW_PREFIX --optimize=1
  install -D -m644 LICENSE "${pkgdir}/$MINGW_PREFIX/share/licenses/python2-cycler/LICENSE"
}

package_mingw-w64-i686-python2-cycler() {
  package_python2-cycler
}

package_mingw-w64-i686-python3-cycler() {
  package_python3-cycler
}

package_mingw-w64-x86_64-python2-cycler() {
  package_python2-cycler
}

package_mingw-w64-x86_64-python3-cycler() {
  package_python3-cycler
}
